version 14.2
set more off

***************************************************************************************************************************
* THIS ROUTINE GENERATES FIGURE A.VIII OF WASEEM (2020) ROLE OF WITHHOLDING ...
***************************************************************************************************************************

use						"$project_data\STPAK_1996_2003_UBP_v1.dta", clear
keep                	if business_sts=="1" | business_sts=="2"
g						ind=real(substr(item_cd,1,4))
drop					if ind<1600
drop					if ind>=2500 & ind<2800
g						treat=business_sts=="1"
drop					if fy==1996
drop					period
g						period=mofd(taxperiod)
qui						sum period
replace					period=period-r(min)+1
bys						period treat: g index=_n
bys						regnor period:egen output_ag=sum(output)
bys						regnor period:egen input_ag=sum(input)
local					var="impopurch_ag"
g						logvar_real=log(`var')
qui						areg logvar_real i.period if treat==1, absorb(regnor)
g 						betahats=0
qui						sum period
local					nr=r(max)
forvalue				s=1/`nr' {
						cap replace betahats=_b[`s'.period] if period==`s' & treat==1
}
qui						areg logvar_real i.period if treat==0, absorb(regnor)
forvalue				s=1/`nr' {
						cap replace betahats=_b[`s'.period] if period==`s' & treat==0
}
#d						;
twoway  				(connected  betahats period if period>1 & index==1 & treat==1,sort lwidth(thick) lcolor(red) mcolor(red) msymbol(o))
						(connected  betahats period if period>1 & index==1 & treat==0,sort lwidth(thick) lcolor(midblue) mcolor(midblue) msymbol(o) lpattern(shortdash)),
						xtitle("Month of the Year") xscale(titlegap(*10))
						xlabel(1 "97" 13 "98" 25 "99" 37 "00" 49 "01" 61 "02" 73 "03" 85 "04")
						yscale(r(0))  yscale(titlegap(*10)) ytitle("Within-firm Mean of Log Imported Inputs") ylabel(-2(1)2)
						xline(13 25 37, lpatter(dash) lcolor(green)) 
						legend(region(style(none)) label(1 "Manufacturers") label(2 "Importers"))
						graphregion(fcolor(white) style(none) color(white) margin(0 0 0 2)) bgcolor(white);
graph 					export "$project_output\PanelDD_lnImportedInputs_UBP.eps", replace;
#d						cr

